<template>
    <StElSelect :value="value" :datas="computedDictItemUrl"
                v-on:focus="($event)=>{$emit('focus', $event)}"
                v-on:blur="($event)=>{$emit('blur', $event)}"
                v-on:change="(val)=>{$emit('change', val)}"
                v-on:input="(val)=>{$emit('input', val)}"
                v-on:data="(val)=>{$emit('data', val)}"
                :disabled="disabled"
                :readonly="readonly"
                :origin-prop="originProp"
                :is-group="groupType == 'groupItem'"
    >

    </StElSelect>
</template>

<script>
    export default {
        name: "StElSelectDict",
        props: {
            value: {},
            // 被包装组件的原始属性
            originProp: {
                type: Object,
                default: function () {
                    return {}
                }
            },
            disabled: Boolean,
            readonly: Boolean,
            // 字典组编码
            groupCode: {
                type: String,
            },
            // 查询类型，item,group,groupItem
            groupType:{
                type: String,
                default: 'item'
            },
            // 私有标识
            privateFlag: String,
            // 分组标识
            groupFlag: String,
            // 标签
            tags: String

        },
        computed: {
            computedDictItemUrl() {
                if(!this.groupCode){
                    return []
                }
              if ('item' == this.groupType) {
                return this.$stUrlTools.appendParam(this.dictItemUrl,{groupCode: this.groupCode,privateFlag: this.privateFlag, groupFlag: this.groupFlag,tags: this.tags})

              }else if ('group' == this.groupType) {
                return this.$stUrlTools.appendParam(this.dictGroupUrl,{groupCodes: this.groupCode,privateFlag: this.privateFlag, groupFlag: this.groupFlag})

              }else if ('groupItem' == this.groupType) {
                return this.$stUrlTools.appendParam(this.dictGroupItemUrl,{groupCode: this.groupCode,privateFlag: this.privateFlag, groupFlag: this.groupFlag,tags: this.tags})

              }

            }
        },
        data() {
            return {
                dictItemUrl: this.$stObjectTools.getValue(this.$scatterConfig,'StElSelectDict.dictItemUrl') || '/dict/getItems',
                dictGroupItemUrl: this.$stObjectTools.getValue(this.$scatterConfig,'StElSelectDict.dictGroupItemUrl') || '/dict/getGroupItems',
                dictGroupUrl: this.$stObjectTools.getValue(this.$scatterConfig,'StElSelectDict.dictGroupUrl') || '/dict/getGroups'
            }
        },
        methods: {}
    }
</script>

<style scoped>

</style>